//package com.fowo.api.service.handleWork;
//
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.fowo.api.entity.PurchaseOrder;
//import com.fowo.api.entity.PurchaseOrderProduct;
//import com.fowo.api.model.process.product.ProcessProductVo;
//import com.fowo.api.model.process.product.item.ProcessProductItemItemVo;
//import com.fowo.api.model.purchase.order.PurchaseOrderProcessingOrderAction;
//import com.fowo.api.model.purchase.order.PurchaseOrderVo;
//import com.fowo.api.service.ProcessProductItemService;
//import com.fowo.api.service.PurchaseOrderProductService;
//import com.fowo.api.service.impl.ProcessProductServiceImpl;
//import com.fowo.api.service.impl.PurchaseOrderBaseServiceImpl;
//import com.fowo.api.service.impl.PurchaseOrderProductServiceImpl;
//import org.springframework.stereotype.Component;
//import org.springframework.util.Assert;
//
//import javax.annotation.Resource;
//import java.math.BigDecimal;
//import java.util.ArrayList;
//import java.util.List;
//
//@Component
//public class purchaseOrderProcessingOrder implements PurchaseOrderProcessingOrderAction {
//
//    @Resource
//    private PurchaseOrderBaseServiceImpl purchaseOrderBaseService;
//
//    @Resource
//    protected PurchaseOrderProductServiceImpl purchaseOrderProductService;
//    @Resource
//    private ProcessProductServiceImpl processProductService;
//    @Resource
//    protected ProcessProductItemService processProductItemService;
//
//    //下推加工单
//    @Override
//    public void run(Long id) throws Exception {
//
//        PurchaseOrderVo voById = purchaseOrderBaseService.getVoById(id);
//        Assert.isTrue(voById.getStauts().equals("1"),"未审核!");
//        List<PurchaseOrderProduct> list = purchaseOrderProductService.list(Wrappers.<PurchaseOrderProduct>query().lambda().eq(PurchaseOrderProduct::getPurchaseOrderId, id));
//        AddPurchaseOrder(voById,list);
//
//    }
//
//    public void AddPurchaseOrder(PurchaseOrderVo voById, List<PurchaseOrderProduct> list){
//        List<ProcessProductItemItemVo> processProductItems=new ArrayList<>();
//        ProcessProductVo model =new ProcessProductVo();
//        model.setStatus("0");
//        model.setRemarks(voById.getRemarks()!=null?voById.getRemarks()+"采购单号:"+voById.getPurchaseOrderCode():"采购单号:"+voById.getPurchaseOrderCode());
//        //循环
//        for(int i=0;i<list.size();i++){
//            PurchaseOrderProduct purchaseOrderProduct = list.get(i);
//            ProcessProductItemItemVo ProcessProductItemItemVo=new ProcessProductItemItemVo();
////            ProcessProductItemItemVo.setPrice(purchaseOrderProduct.ge);
//            ProcessProductItemItemVo.setNum(purchaseOrderProduct.getApplicationNum()!=null?new BigDecimal(purchaseOrderProduct.getApplicationNum()):null);
//            ProcessProductItemItemVo.setProductId(purchaseOrderProduct.getProductId());
//            ProcessProductItemItemVo.setSku(purchaseOrderProduct.getSku());
//            processProductItems.add(ProcessProductItemItemVo);
//        }
//        model.setProcessProductItems(processProductItems);
//        try {
//            processProductService.create(model);
//        } catch (Exception e) {
//            throw new RuntimeException("");
//        }
//
//    }
//}
